<?php
$title = "OnlineShop- List";
$css = "itemList.css";
include_once 'common/top.php';
include_once '../Class/DB.php';
if(!$_SESSION["Passed"])
{
echo '<br><br><h3 align="center">You have not login.<h3>';
exit();
}
$db=new DB();
$delete_did=$_GET["delete_did"];
$add_pid=$_GET["add_pid"];
if(!isset($delete_did))
{
	
}
else {
	$db->delete_did($delete_did);
	?>
<script language="JavaScript">
window.location.href="itemList.php";
</script>	
<?php 
}

if(!isset($add_pid))
{
	
}
else {
	$db->add_to_designList($_SESSION["User"]["uid"], $add_pid);
}

$theDesign=$db->get_uid_decorate($_SESSION["User"]["uid"]);
//print_r($theDesign);
//exit();
?>
<div id="itemList">
	<table>
		<tr>
			<th width="80">
				<p>Product Id</p>
			</th>
			<th width="250">
				<p>Product Name</p>
			</th>
			<th width="120">
				<p>Price</p>
			</th>
			<th width="80">
				<p>Operation</p>
			</th>
		</tr>
		<?php 
		$i=0;
		while(isset($theDesign[$i]))
		{
			$theProduct=$db->get_pid_product($theDesign[$i]["pid"]);
		?>
		<tr>
			<td>
				<p><?php echo $theProduct[0]["pid"];?></p>
			</td>
			<td>
				<p><?php echo $theProduct[0]["p_name"];?></p>
			</td>
			<td>
				<p><?php echo $theProduct[0]["act_price"];?></p>
			</td>
			<td>
				<a href="itemList.php?delete_did=<?php echo $theDesign[$i]["did"];?>"><img style="width:15px; height:15px" alt="delete" src="../Image/delete.png"/></a>
			</td>
		</tr>
		<?php 
		$i++;
		}
		?>
	</table>
	
	<div id="link">
		<a href="design.php">>>Go To Design My House<<</a>
	</div>
</div>
<?php
include_once 'common/tail.php';
?>